Oracle Reports Building Reports 10g (9.0.4) Part Number B10602-01 |
|
Text description of the illustration simplejsp_rpf.gif
Text description of the illustration simplejsp_fin.gif
Oracle Reports enables you to build reports where certain criteria are defined at runtime. To enable your users to define the criteria at runtime, you can use Parameter Forms. The steps in this chapter show you how to build an HTML Parameter Form using JavaServer Pages for a JSP-based Web report. To build a Parameter Form for a paper report, refer to the Reports Builder Online Help. This chapter shows you how to build a very simple Parameter Form. If this Parameter Form does not suit your needs, refer to a more advanced example located in the Getting Started with Oracle Reports Web site on the Oracle Technology Network (http://otn.oracle.com/products/reports/
).
For conceptual information about JSPs and Parameter Forms for Web reports, refer to Section 2.2.1, "About JavaServer Pages (JSPs) and servlets" and Section 1.9.4, "About Parameter Forms for Web reports".
Suppose you have an existing JSP-based Web report that shows a bar graph of employee salaries per department, as well as a tabular report that shows the employee details. Now, your customers want to be able to specify at runtime the employee information for a specific department, so that they don't have to read the data for all departments. The steps in this report will show you how to add a JSP Parameter Form to this Web report.
This example uses the resulting report from the Oracle Reports Tutorial. If you'd like to learn how to build the Web report that we use in this chapter, follow the steps in the tutorial.
Feature | Location |
---|---|
Use a text or HTML editor to create a simple HTML Parameter Form. |
|
Use the Data Model and Web Source views in Reports Builder to modify the Parameter Form and save as a JSP. |
Section 39.3, "Modify the HTML Parameter Form in Reports Builder" |
Use the Data Model view to modify the query for the target report to accept user parameters. |
|
Test the deployment of the JSP Parameter Form and Web report. |
To build the examples in this manual, you must have the example files we've provided, as well as access to the sample schema that is shipped with the Oracle9i database.
If you haven't already done so, you can download the files you'll need to complete this example from the Oracle Technology network (http://otn.oracle.com/products/reports
) and install them on your machine.
http://otn.oracle.com/product/reports
).
simplejsppf.zip
into a temporary directory on your machine (e.g., d:\temp
).
d:\orawin90\examples
).
This zip file contains the following files:
If you don't know if you have access to the sample schema provided with the Oracle9i database, contact your database administrator. You should have access to the "Human Resources" portion of the schema to complete this example.
The steps in this section will show you how to build a simple Parameter Form using plain HTML. You will then modify this HTML Parameter Form in Reports Builder so that you can call the Parameter Form from your JSP-based Web report.
If you don't want to create your own HTML file, you can open the sample HTML file we've provided in the Source directory, called paramform.html
, then view the source code.
To create a simple Parameter Form in HTML:
<form name="form1" method="post" action=""> <select name="p_department" size="1"> <option value="1">a</option> </select> <br> <input type="text" name="userid" value="hr/hr@db-connect"> <br> <input type="submit" name="Submit" value="Run Report"> </form>
paramform_<your initials>.html
. When you display this HTML file in a Web browser, it should look similar to the following image:
Text description of the illustration simplejsp_html.gif
In this section, you will learn how to modify an HTML Parameter Form in Reports Builder to populate the list of values (LOV) you created with values from a data source. You will use JSP tags for Oracle Reports to enable the Parameter Form to access elements from a data model.
The steps in this section will show you how to create a simple data model for the Parameter Form.
paramform_<your initials>.html
.
select department_name, department_id from departments order by department_name
Text description of the illustration simplejsp_dm.gif
In this section, you will learn how to modify the Web source to pull data into the existing list of values (LOV) in your Parameter Form. This data will rely on the data model you created in the previous section. We will also examine the code to explain how each element operates.
<select name="p_department" size="1">
<option value="1">a</option>
</select>
Since the LOV is currently static, we need to change this HTML element to dynamically retrieve data based on our data model.
<select name=" p_department"> <rw:foreach id="fn" src="G_department_name"> <option value="<rw:field id="f_deptId" src="department_id"/>"><rw:field id="deptname1" src="department_name"/></option> </rw:foreach> </select>
By using JSP tags for Oracle Reports in the above code, we retrieve data into the Parameter Form's LOV by basing the parameters on fields in the data model. Let's examine each element:
<option>
: The display name of the LOV is replaced by the field department_name
from the data model. When the user displays the Parameter Form, the department name will display in the list.
<rw:field>
: This element accesses each element of the g_department_name
group.
<rw:foreach>
: This element iterates through the results based on the g_department_name
group in the data model.
src
: This parameter for the <rw:for each>
element must match the group name of the data model.
<rw:field id>
: This parameter can be any value, but it must be unique.
By making these modifications to the code, we've replaced the return value attribute of the LOV with the field department_id
, based on the data model we created in the previous section. If we now choose a department name from the list of values, its related department ID is returned. Note that the return value is not displayed.
Now that we've modified and examined our Web source, let's view the Parameter Form in a Web browser.
Text description of the illustration simplejsp_pfv.gif
Now that you've set up the parameters, the next step is to set up the target report to accept the parameters. Then, we will define the action for your Parameter Form. When a user clicks the Run Report button, the target report will be run based on the Department and User ID parameters.
The target report we use in this section is the sample report for the Oracle Reports Tutorial. If you completed the exercises in the Oracle Reports Tutorial and created "emprevb.jsp," you can use that report in this section. Otherwise, you can use the example file we've suppled, called emprev_final.jsp
. We will not show the steps to build this report in this section.
For more information on building the sample JSP-based Web report, refer to the Oracle Reports Tutorial.
emprev_final.jsp
.
WHERE (EMPLOYEES.MANAGER_ID = EMPLOYEES_A1.EMPLOYEE_ID) AND EMPLOYEES.DEPARTMENT_ID = 100
WHERE (EMPLOYEES.MANAGER_ID = EMPLOYEES_A1.EMPLOYEE_ID) AND EMPLOYEES.DEPARTMENT_ID = :P_DEPARTMENT
emprev_param_<your initials>.jsp
.
To deploy the JSP Parameter Form and the target JSP-based Web report, you must copy paramform_<your initials>.jsp
and emprev_final_<your initials>.jsp
to the deployment directory of your Application Server. For testing purposes, however, you can use the OC4J instance shipped with the Oracle Developer Suite. Once you've placed the target report in the desired directory, you can then modify the Parameter Form to point to the report location.
For more information on deploying a JSP-based Web report, refer to the Oracle Application Server Reports Services Publishing Reports to the Web manual.
paramform_<your initials>.jsp
and emprev_param_<your initials>.jsp
) into the following directory:
Oracle_Home\reports\j2ee\reports_ids\web
Oracle_Home
\reports\j2ee\reports_ids\web\paramform_<your initials>.jsp
.
emprev_param_<your initials>.jsp
report executes based on the selected parameters. The line of code should look like this:
<form name="form1" method="post" action="/reports/emprev_param_<your initials>.jsp">
<IDS_HOME>
/j2ee/DevSuite/startinst.sh
http://<machine name>:8888/reports/paramform_<your initials>.jsp?userid=<userid>/<password>@<database name>
In our example, we would use:
http://mycomputer-pc:8888/reports/paramform.jsp?userid=hr/hr@orcl
Note:
The connect string you type in the URL is for the database you used to create the data model in Section 39.3.1, "Create a data model manually for the Parameter Form". For the purposes of this example, we've used plain text to pass the connect string. For information on using security, refer to the Securing Oracle Reports white paper, located on the Getting Started with Oracle Reports Web site on the Oracle Technology Network ( |
emprev_param_<your initials>.jsp
report uses. For example, hr/hr@orcl
:
Text description of the illustration simplejsp_rpf.gif
Text description of the illustration simplejsp_fin.gif
Congratulations! You have created a JSP Parameter Form for an existing Web report. You now know how to:
For more information on deploying JSP-based Web reports, refer to the Oracle Application Server Reports Services Publishing Reports to the Web manual. For more information on any of the wizards, views, or properties used in this example, refer to the Reports Builder Online Help, which you can access in two ways:
http://otn.oracle.com/products/reports/
), click Documentation and navigate to the Reports Builder Online Help for the most recent, hosted online help.
|
![]() Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. | | Ad Choices. |
|